<?php
//+-----------------------------------------------------------
//| 人生是荒芜的旅行，冷暖自知，苦乐在心
//+-----------------------------------------------------------
//| Author:Janmas <janmas@126.com>
//+-----------------------------------------------------------
//| 
//+-----------------------------------------------------------


namespace app\admin\controller;


use app\common\plugins\PluginModel;

/**
 * Class Menu
 * @package app\admin\controller
 * @property \app\admin\service\Menu $service
 */
class Menu extends Admin
{
	protected $noNeedLogin = [];

	protected $noNeedAuth = [];


	public function index()
	{
		if ( $this->request->isPost() ){
			return $this->service->getTableList();
		}
		return $this->fetch();
	}

	public function create()
	{
		if ( $this->request->isPost() ){
			return $this->service->create();
		}
        $flag = \app\admin\model\Plugin::column('name','flag');
		$flag =  ['admin'=>'系统模块']+$flag;
		$this->assign('flag',$flag);
		$this->assign('menu_type',$this->service->getModel()->menuType);
		return $this->fetch();
	}


	public function update( $id = null )
	{
		if ( $this->request->isPost() ){
			$this->service->update();
		}
		$info = $this->service->getModel()->find($id);
		$this->assign('info', $info);
        $flag = \app\admin\model\Plugin::column('name','flag');
        $flag =  ['admin'=>'系统模块']+$flag;
        $this->assign('flag',$flag);
		$this->assign('menu_type', $this->service->getModel()->menuType);
		return $this->fetch();
	}

	public function delete(){
		return $this->service->delete();
	}

	public function getSelectTree()
	{
		return $this->service->getSelectTree();
	}

	public function getTree(){
	    return $this->service->getTreeComponets();
    }
}